﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TjZheng.Framework;
using TjZheng.WeiXin.Business;
using TjZheng.WeiXin.DataEntity;
using TjZheng.Cache;

namespace TjZheng.WeiXin.SDK.Pay
{
    public abstract class NativePay
    {
        public MerchantInfo MerchantInfo { get; private set; }
        public NativePay(string appId)
        {
            BizMerchantInfo objBizMerchantInfo = new BizMerchantInfo();
            MerchantInfo objMerchantInfo = objBizMerchantInfo.GetRecordCache("", TimeSpan.FromSeconds(30), "AppId=@AppId AND IsRelease=1", new { AppId = appId });
            if (objMerchantInfo == null)
            {
                throw new ArgumentNullException("缺少商户配置信息");
            }
            this.MerchantInfo = objMerchantInfo;
        }
        public NativePay(int merchantId)
        {
            BizMerchantInfo objBizMerchantInfo = new BizMerchantInfo();
            MerchantInfo objMerchantInfo = objBizMerchantInfo.GetRecordCache("", merchantId, TimeSpan.FromSeconds(30));
            if (objMerchantInfo == null)
            {
                throw new ArgumentNullException("缺少商户配置信息");
            }
            this.MerchantInfo = objMerchantInfo;
        }
        public NativePay(MerchantInfo objMerchantInfo)
        {
            if (objMerchantInfo == null)
            {
                throw new ArgumentNullException("缺少商户配置信息");
            }
            this.MerchantInfo = objMerchantInfo;
        }
        public abstract InvokeResult CreatePayUrl(WxPayPackage objWxPayPackage);
    }
}
